<!-- 燃烧炉 -->
<template>
  <div class="app-container">
    <el-row :gutter="20">
      <el-col :span="show ? rowObj.T1 : rowObj.F1" :xs="show ? rowObj.T2 : rowObj.F2">
        <workSiteLeft ref="workSiteLeft" :show="show" @showLeft="showLeft" @queryVal="queryVal" />
      </el-col>
      <el-col :span="show ? rowObj.T3 : rowObj.F3" :xs="show ? rowObj.T4 : rowObj.F4">
        <el-form :model="queryParams" ref="queryForm" size="mini" :inline="true" v-show="showSearch">
          <!-- <el-form-item label="工地名称" prop="baseCode">
            <el-select v-model="queryParams.baseCode" clearable size="mini" placeholder="请选择工地名称">
              <el-option v-for="item in constructionList" :key="item.code" :label="item.name" :value="item.code"></el-option>
            </el-select>
          </el-form-item> -->
          <el-button style="margin-right: 6px" size="mini" :icon="show ? 'el-icon-s-fold' : 'el-icon-s-unfold'" circle @click="showLeft(show)"></el-button>
          <!-- <el-form-item label="试验设备" prop="deviceId">
            <el-select v-model="queryParams.deviceId" clearable size="mini" placeholder="请选择试验设备">
              <el-option v-for="item in equipmentList" :key="item.id" :label="item.name + ' ' + item.model" :value="item.id"></el-option>
            </el-select>
          </el-form-item> -->
          <el-form-item label="关联状态" prop="relevance">
            <el-select style="width: 100px" v-model="queryParams.relevance" clearable size="mini" placeholder="请选择">
              <el-option v-for="item in stateList" :key="item.id" :label="item.name" :value="item.id"></el-option>
            </el-select>
          </el-form-item>
          <el-form-item label="是否合格" prop="eligible">
            <el-select style="width: 100px" v-model="queryParams.eligible" clearable size="mini" placeholder="请选择">
              <el-option v-for="item in eligibleList" :key="item.id" :label="item.name" :value="item.id"></el-option>
            </el-select>
          </el-form-item>
          <el-form-item label="试验时间">
            <deatetime ref="deatetime" v-model="queryParams.time"> </deatetime>
          </el-form-item>
          <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery" v-hasPermi="['laboratoryManage:combustionFurnaceData:query']">搜索</el-button>
          <!-- <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button> -->
        </el-form>
        <el-table border v-loading="loading" :data="cementDataList" size="mini">
          <!-- <el-table-column label="所属单位" align="center" prop="deptName" width="115" show-overflow-tooltip/> -->
          <el-table-column label="所属试验室" align="center" prop="deviceLaboratoryName" show-overflow-tooltip />
          <el-table-column label="设备名称" align="center" prop="deviceName" show-overflow-tooltip />
          <el-table-column label="型号/规格" align="center" prop="deviceModel" show-overflow-tooltip />
          <el-table-column label="时间" align="center">
            <template slot-scope="scope">
              <span>{{ scope.row.min + scope.row.second || "-" }}</span>
            </template>
          </el-table-column>
          <el-table-column label="初始重量" align="center">
            <template slot-scope="scope">
              <span>{{ scope.row.originalWeight || "-" }}</span>
            </template>
          </el-table-column>
          <el-table-column label="实时重量" align="center">
            <template slot-scope="scope">
              <span>{{ scope.row.realTimeWeight || "-" }}</span>
            </template>
          </el-table-column>
          <el-table-column label="实时温度" align="center">
            <template slot-scope="scope">
              <span>{{ scope.row.realTimeTemp || "-" }}</span>
            </template>
          </el-table-column>

          <el-table-column label="创建时间" align="center" width="165">
            <template slot-scope="scope">
              <span>{{ scope.row.createTime || "-" }}</span>
            </template>
          </el-table-column>

          <el-table-column fixed="right" label="操作" align="center" width="120" class-name="small-padding fixed-width">
            <template slot-scope="scope">
              <el-button size="mini" type="text" @click="handleDetails(scope.row)" v-hasPermi="['laboratoryManage:combustionFurnaceData:details']">查看详情</el-button>
              <!-- <el-button size="mini" type="text" @click="handleDetails(scope.row)" >绑定样品</el-button> -->
            </template>
          </el-table-column>
        </el-table>

        <pagination v-show="total > 0" :total="total" :page.sync="queryParams.pageNum" :limit.sync="queryParams.pageSize" @pagination="getList" />
      </el-col>
    </el-row>
    <!-- 详情 -->
    <el-dialog title="试验实时数据" :visible.sync="rowDetailsDialog" width="80%">
      <el-table border v-loading="loadingTwo" :data="detailsList" size="mini">
        <el-table-column label="序号" type="index" align="center" width="50" />
        <el-table-column prop="deviceName" label="设备名称" align="center" show-overflow-tooltip min-width="140">
        </el-table-column>
        <el-table-column prop="deviceModel" label="型号/规格" align="center" min-width="110">
        </el-table-column>
        <el-table-column prop="description" label="数据标志" align="center" min-width="110">
          <template slot-scope="scope">
            <el-tag :type="'01' == scope.row.flag ? 'success' : 'danger'">{{ scope.row.description }}</el-tag>
          </template>
        </el-table-column>
        <el-table-column prop="second" header-align="center" align="center" min-width="110" label="时间">
          <template slot-scope="scope">
            <span v-if="scope.row.min">{{ scope.row.min }}分</span><span v-if="scope.row.second">{{ scope.row.second }}秒</span>
          </template>
        </el-table-column>
        <el-table-column prop="originalWeight" header-align="center" align="center" min-width="110" label="初始重量"></el-table-column>
        <el-table-column prop="realTimeWeight" header-align="center" align="center" min-width="110" label="实时重量"> </el-table-column>
        <el-table-column prop="realTimeTemp" header-align="center" align="center" min-width="110" label="实时温度"></el-table-column>
        <el-table-column prop="createTime" header-align="center" align="center" min-width="160" show-overflow-tooltip label="创建时间"></el-table-column>
      </el-table>

      <pagination v-show="totalTwo > 0" :total="totalTwo" :page.sync="queryParamsTwo.pageNum" :limit.sync="queryParamsTwo.pageSize" @pagination="getDetailsList" />
      <span slot="footer" class="dialog-footer">
        <el-button @click="rowDetailsDialog = false" size="mini">取 消</el-button>
      </span>
    </el-dialog>
  </div>
</template>

<script>
import workSiteLeft from "@/views/components/workSiteLeft";
import deatetime from "@/components/Datetime";

import { deptList, laboratoryDeviceLIist } from "@/api/common/common";
import {
  combustionFurnaceDataList,
  combustionFurnaceDatalDetails,
} from "@/api/laboratoryManage/combustionFurnaceData";

export default {
  name: "combustionFurnaceData", //燃烧炉数据
  data() {
    return {
      eligibleList: [
        { id: "0", name: "不合格" },
        { id: "1", name: "合格" },
      ],
      stateList: [
        { id: "0", name: "未关联" },
        { id: "1", name: "已关联" },
      ],
      show: true,
      rowObj: {
        T1: 3,
        T2: 24,
        T3: 21,
        T4: 24,
        F1: 0,
        F2: 0,
        F3: 24,
        F4: 24,
      },
      equipmentList: [],
      rowId: "",
      detailsList: [], //详情列表
      queryParamsTwo: {
        pageNum: 1,
        pageSize: 10,
      },
      totalTwo: 0,
      loadingTwo: false,
      constructionList: [], //工地列表
      rowDetailsDialog: false,
      // 按钮loading
      buttonLoading: false,
      // 遮罩层
      loading: true,
      // 选中数组
      ids: [],
      // 非单个禁用
      single: true,
      // 非多个禁用
      multiple: true,
      // 显示搜索条件
      showSearch: true,
      // 总条数
      total: 0,
      // 水稳拌合站数据表格数据
      cementDataList: [],
      // 弹出层标题
      title: "",
      // 是否显示弹出层
      open: false,
      // 查询参数
      queryParams: {
        pageNum: 1,
        pageSize: 10,
      },
    };
  },
  components: {
    deatetime,
    workSiteLeft,
  },

  created() {
    //this.getEquipmentList();

    // this.getProjectList();

    this.getList();
  },
  methods: {
    /** 查询工地列表 */
    getProjectList() {
      deptList().then((res) => {
        this.constructionList = res || [];
      });
    },
    /** 查询试验设备列表 */
    getEquipmentList() {
      laboratoryDeviceLIist({
        name: "燃烧",
      }).then((res) => {
        this.equipmentList = res.data;
      });
    },

    /** 查询数据列表 */
    getList() {
      this.loading = true;
      combustionFurnaceDataList(this.queryParams).then((response) => {
        this.cementDataList = response.rows;
        this.total = response.total;
        this.loading = false;
      });
    },

    /** 搜索按钮操作 */
    handleQuery() {
      this.queryParams = this.getSearchParams();
      this.queryParams.pageNum = 1;
      this.getList();
    },
    getSearchParams() {
      const params = {};
      for (const key in this.queryParams) {
        if (key === "time") {
          const time = this.queryParams[key];
          if (time && time.length === 2) {
            params.startTime = time[0];
            params.endTime = time[1];
          }
        } else {
          params[key] = this.queryParams[key];
        }
      }
      return params;
    },
    /** 重置按钮操作 */
    resetQuery() {
      this.$refs.workSiteLeft.resetQuery();
      this.queryParams.id = "";
      this.$refs.deatetime.startTime = null;
      this.$refs.deatetime.endTime = null;
      this.queryParams.time = [];
      this.queryParams.startTime = "";
      this.queryParams.endTime = "";
      this.resetForm("queryForm");
      this.handleQuery();
    },
    handleDetails(row) {
      this.rowId = row.id;
      this.queryParamsTwo.pageNum = 1;
      this.queryParamsTwo.pageSize = 10;
      combustionFurnaceDatalDetails({
        ...this.queryParamsTwo,
        id: row.id,
      }).then((res) => {
        console.log(res);
        this.detailsList = res.rows;
        this.totalTwo = res.total;
        this.rowDetailsDialog = true;
      });
    },
    getDetailsList() {
      this.loadingTwo = true;
      combustionFurnaceDatalDetails({
        ...this.queryParamsTwo,
        id: this.rowId,
      }).then((response) => {
        this.detailsList = response.rows;
        this.totalTwo = response.total;
        this.loadingTwo = false;
      });
    },
    handleClose() {
      this.$confirm("确认关闭？")
        .then((_) => {
          F;
          done();
        })
        .catch((_) => { });
    },
    showLeft(show) {
      this.show = !show;
    },
    queryVal(val) {
      this.queryParams.id = val.id;
      this.handleQuery();
    },
  },
};
</script>
<style scoped lang="scss">
.app-combustionFurnaceData {

  // padding-top: 16px;
  // user-select: none;
  .chartBox {
    height: 350px;
    width: 100%;
    position: relative;
  }

  .chartBoxHeight {
    height: 400px;
    width: 100%;
    position: relative;
  }

  .chartSearch {
    position: absolute;
    top: 0px;
    right: 60px;
  }
}
</style>

